package cn.js.servlet;

import cn.js.dao.powerbattery.SysPowerbatteryMapper;
import cn.js.pojo.Powerbattery;
import cn.js.utils.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/PowerBatteryByidServlet")
public class PowerBatteryByidServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");

        int id = Integer.parseInt(request.getParameter("id"));
        SqlSession sqlSession = MyBatisUtil.createSqlSession();
        Powerbattery powerbattery= sqlSession.getMapper(SysPowerbatteryMapper.class).selectId(id);
        if (powerbattery != null) {
            request.setAttribute("powerbattery",powerbattery);
        }



        request.getRequestDispatcher("powerbatteryUpdate.jsp").forward(request,response);

    }

}
